package com.base;

import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;

import java.util.concurrent.TimeUnit;

public class Main {

    public static void main(String[] args) throws InterruptedException {

        Config config = new Config();
        /*SingleServerConfig setDatabase = config.useSingleServer()
                .setAddress("redis://127.0.0.1:6379")
                .setDatabase(0);*/
        SingleServerConfig setDatabase = config.useSingleServer()
                .setAddress("redis://10.250.14.145:6379")
                .setPassword("ltkj2020")
                .setDatabase(1);

        RedissonClient redisson = Redisson.create(config);

        RLock lock = redisson.getLock("anyLock");
        lock.lock();


        System.out.println("11111111111111");
        Thread.sleep(15000);

        lock.unlock();

        lock.tryLock(100, TimeUnit.SECONDS);




        RMap<String, Object> map = redisson.getMap("anyMap");
        map.put("foo", "bar");

        map = redisson.getMap("anyMap");
        System.out.println(map.get("foo"));


    }

}
